<template>
  <div>
      <p>用户名：<input type="text" v-model = 'username'></p>
      <p>密码：<input type="text" v-model = 'password'></p>
      <button @click="login">登录</button>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            username:'',
            password:'',
        }
    },
    methods:{
        login(){
            var formdata= new FormData
            formdata.append('username',this.username)
            formdata.append('password',this.password)
            axios.post('http://127.0.0.1:8000/myapp/login/',formdata).then(res=>{
                console.log(res.data)
                if(res.data.code==200){
                    sessionStorage.setItem('uid',res.data.uid)
                    window.location.href = '/show_ding'
                }
            })
        }
    }
}
</script>

<style>

</style>